package com.jt.www.biz.agree.service.impl;

import com.jt.www.biz.agree.service.ProtocolService;
import com.jt.www.dao.mapper.woxuebao.ProtocolLogMapper;
import com.jt.www.domain.enums.common.IsDeletedEnum;
import com.jt.www.domain.po.ProtocolLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.weekend.Weekend;
import tk.mybatis.mapper.weekend.WeekendCriteria;

/**
 * 协议阅读日志
 * Created by shaoyn on 2020/02/25.
 */
@Service
public class ProtocolServiceImpl implements ProtocolService {

    @Autowired
    private ProtocolLogMapper protocolLogMapper;

    @Override
    public int agreeWithProtocol(ProtocolLog protocolLog) {
        return protocolLogMapper.insertSelective(protocolLog);
    }

    @Override
    public int selectProtocolLogByUserCode(String userCode, String protocolType) {
        Weekend<ProtocolLog> weekend = Weekend.of(ProtocolLog.class);
        WeekendCriteria<ProtocolLog, Object> criteria = weekend.weekendCriteria();
        criteria.andEqualTo(ProtocolLog::getUserCode, userCode);
        criteria.andEqualTo(ProtocolLog::getProtocolType, protocolType);
        criteria.andEqualTo(ProtocolLog::getIsDeleted, IsDeletedEnum.NO.getValue());
        return protocolLogMapper.selectCountByExample(weekend);
    }


}
